package cn.yuanqiao.web.controller.manage;/**
 * @author 赵常飞
 * @date 2024/1/24 16:53
 */

import cn.yuanqiao.common.core.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.core.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import cn.yuanqiao.manage.domain.YqdaGdfwAndBgqx;
import cn.yuanqiao.manage.domain.YqdaGdfwAndBgqxRule;
import cn.yuanqiao.manage.service.IGdfwAndBgqxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *@Author: 赵常飞
 *@Date: 2024/1/24 16:53
 *@Description:
 *@Note:
 */
@RestController
@RequestMapping("/manage/gdfwandbgqx")
public class GdfwAndBgqxController extends BaseController {
    @Autowired
    private IGdfwAndBgqxService iGdfwAndBgqxService;
    @Log(title = "获取归档范围和保管期限树", businessType = BusinessType.SELECT)
    @GetMapping("/gettree/{categoryId}")
    public AjaxResult getcatemodeltree(@PathVariable("categoryId") Long categoryId){
        return success(iGdfwAndBgqxService.selectTreeList(categoryId));
    }


    @Log(title = "新增制度", businessType = BusinessType.INSERT)
    @PostMapping("/addzd")
    public AjaxResult addzd(@RequestBody YqdaGdfwAndBgqx gdfwAndBgqx){
        return success(iGdfwAndBgqxService.addzd(gdfwAndBgqx));
    }

    @Log(title = "修改制度", businessType = BusinessType.UPDATE)
    @PostMapping("/editzd")
    public AjaxResult editzd(@RequestBody YqdaGdfwAndBgqx gdfwAndBgqx){
        return success(iGdfwAndBgqxService.editzd(gdfwAndBgqx));
    }


    @Log(title = "查询制度列表", businessType = BusinessType.SELECT)
    @GetMapping("/gettable/{parentId}/{categoryId}")
    public TableDataInfo gettable(@PathVariable("parentId")Long parentId,@PathVariable("categoryId")Long categoryId)
    {
        startPage();
        List<YqdaGdfwAndBgqx> list = iGdfwAndBgqxService.gettable(parentId,categoryId);
        return getDataTable(list);
    }

    @Log(title = "新增制度条件", businessType = BusinessType.INSERT)
    @PostMapping("/addtj")
    public AjaxResult addtj(@RequestBody YqdaGdfwAndBgqxRule gdfwAndBgqx){
        return success(iGdfwAndBgqxService.addtj(gdfwAndBgqx));
    }

    @Log(title = "修改制度条件", businessType = BusinessType.UPDATE)
    @PostMapping("/edittj")
    public AjaxResult edittj(@RequestBody YqdaGdfwAndBgqxRule gdfwAndBgqx){
        return success(iGdfwAndBgqxService.edittj(gdfwAndBgqx));
    }

    @Log(title = "获取制度条件列表", businessType = BusinessType.SELECT)
    @GetMapping("/gettjtable")
    public TableDataInfo gettjtable(@RequestParam("zdId") Long zdId,@RequestParam("type") Integer type){
        startPage();
        List<Map<String,Object>> list = iGdfwAndBgqxService.gettjtable(zdId,type);
        return getDataTable(list);
    }

    @GetMapping("/gettjsql")
    public AjaxResult gettjsql(@RequestParam("zdId") Long zdId,@RequestParam("type") Integer type){
        return success(iGdfwAndBgqxService.gettjsql(zdId,type));
    }

    @Log(title = "获取制度详细信息", businessType = BusinessType.UPDATE)
    @PostMapping("/getzd")
    public AjaxResult getzd(@RequestParam("id") Long zdid){
        return success(iGdfwAndBgqxService.getzd(zdid));
    }

    @GetMapping("/delete/{tjid}")
    public AjaxResult delete(@PathVariable("tjid") Long tjid){
        return success(iGdfwAndBgqxService.delete(tjid));
    }
}
